chrome.runtime.connect({name: "hostPage"});

chrome.runtime.onMessage.addListener(function (map) {
    var html = '';
    var keys = Object.keys(map);
    keys.sort(function (a, b) {
        a = a.split("").reverse().join("");
        b = b.split("").reverse().join("");
        return a > b;
    });
    for (var i = 0; i < keys.length; i++) {
        var key = keys[i];
        html += ('<tr><th>' + key + '</th><th>' + map[key] + '</th></tr>');
    }
    document.getElementById('list').innerHTML = html;
});
